import instance  from './request'
import type { 
    signParams,
    BaseResponse, 
    userInfo,
    userList,
    createInfo 
} from "./type";

instance.defaults.baseURL ='http://121.89.213.194:9001'


// 注册接口
export const signList = (params: signParams) => {
    return instance.post<BaseResponse>('/api/register',params)
}

// 登录接口
export const loginApi = (params: signParams) => {
    return instance.post<BaseResponse & { token:string }>('/api/login',params)
}


// 用户信息接口
export const userInfoApi = () => {
    return instance.get<BaseResponse<userInfo>>('/api/user/info',{
        // 需要接收一个请求头  将token 传过去
        // headers:{
        //     Authorization: localStorage.getItem('token')
        // }
    })
}
//  用户列表
export const userListApi = (params:{page:number , pagesize:number}) => {
    return instance.get<BaseResponse<userList>>('/api/userlist', {
      params,
    //   headers:{
    //         Authorization: localStorage.getItem('token')
    //     }
    })
}
// 新增接口
export const createApi = (params:createInfo ) => {
    return instance.post<BaseResponse>('/api/user/create', params)
}

// 编辑接口
export const editApi = (params: createInfo & {id :string}) => {
    return instance.post<BaseResponse>('/api/user/update',params)
}

//删除接口 
export const delApi = (id: string) => {
    return instance.post<BaseResponse>('/api/user/delete', { id })
}

// 抛出导出数据接口
export const exportApi = (ids:string[]) => {
    return instance.post('/api/export', { ids }, { responseType: 'blob' })
                                                    //二进制文件
}
  
  
  
    

   
